const Timestamp = new Date().getTime();
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports = {
  lintOnSave: false,
  publicPath: "./",
  // rules:[
  //     {
  //       test: /\.swf$/,
  //       loader: 'url-loader',
  //       options: {
  //         limit: 1024,
  //         name: 'file/[path][name].[hash:7].[ext]'
  //     }
  //   }
  // ],
  
  chainWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
        // 给js和css配置版本号
        config.output.filename('js/[name].' + Timestamp + '.js').end();
        config.output.chunkFilename('js/[name].' + Timestamp + '.js').end();
        config.plugin('extract-css').tap(args => [{
            filename: `css/[name].${Timestamp}.css`,
            chunkFilename: `css/[name].${Timestamp}.css`
        }])
         
    }
  },
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
         
    }
  },
  devServer: {
    // host:'192.168.0.115',
    port:8080,
    overlay: {
      warning: false,
      errors: false,
    },
    proxy: {
      '/pro': {
        target: 'http',
        changeOrigin: true,
        pathRewrite: {'^/pro': ''}
      }
    }
  },
};
